package com.infinity.springboot.thymeleaf.dao;

import com.infinity.springboot.thymeleaf.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: wuxiang
 * @Description:
 * @Date: Create in 2020/6/16 21:01
 */
public interface UserDao extends JpaRepository<User, Integer> {

    User findByUserName(@Param("userName") String userName);

    /**
     *
     * @param userName
     * @return
     */
    @Modifying
    @Transactional(rollbackFor = Exception.class)
    int deleteByUserName(@Param("userName") String userName);
}
